<!DOCTYPE html>
<html>
<head>
    {include file='public/meta'/}
    <link rel="stylesheet" href="__STATIC_URL__/static/css/bootstrapSwitch.css">
    <script src="__STATIC_URL__/static/js/bootstrapSwitch.js"></script>


</head>
<body>
{include file='public/header'/}
<!------------------导航-------------------------->
<section>
    {include file='public/left'/}
    <!--------------------------主要内容区域------------------------------------->
    <div class="content">

        <div class="panel mgl15 mgr15">
            <div class="panel-body">
                <!--路径导航-->
                <ol class="breadcrumb">
                    <li>当前位置是:</li>


                    <li>
                        <a href="{:url('cardus/cardinfo',['card_id'=>$card['card_id']])}">会员卡管理</a>
                    </li>
                    <li class="active" style="color: #02b87f;">一键开卡</li>
                </ol>
                <div>

                    <div class="alert alert-danger"
                         style="">开启后需进行一键开卡渠道获取二维码，原二维码依旧可使用，但是需要一键开卡二维码才可在会员领卡时使用一键开卡功能。
                    </div>
                        <div class="panel panel-default ng-scope">
                            <div class="panel-heading">
                                一键开卡开关
                            </div>
                            <form action="" method="post" onsubmit="return check()">

                                <div class="panel-body">
                                    <div class="row">
                                        <div class="form-horizontal" data-layout="horizontal">
                                            <div class="form-group">
                                                <input type="hidden" value="{$card['card_id']}" id="card_id">
                                                <input type="hidden" value="{$card['activate']}" id="act">

                                                <label class="col-sm-4 control-label">是否开启：<span class="glyphicon glyphicon-asterisk glyphicon-tip"></span></label>
                                                <div class="col-sm-8">
                                                    <input type="hidden" name="activate" value="0" id="activate">

                                                    <div class="switch" id="self" data-animated="true" data-on-label="开" data-off-label="关">

                                                        <input type="checkbox" id="se" />

                                                    </div>

                                                </div>
                                            </div>
                                        </div>

                                    </div>

                                </div>
                                <div class="panel-footer">
                                    <button class="btn btn-success" type="button" onclick="btn()">提交</button>
                                </div>
                            </form>



                        </div>

                        <div class="panel panel-default ng-scope">
                            <div class="panel-heading">
                                功能说明
                            </div>
                            <div class="panel-body">
                                <p>
                                    <small>开启后可使用微信原生一键开卡功能，领卡激活一步完成，提升开卡成功率。</small>
                                </p>
                                <div class="row">
                                    <div class="col-lg-6">
                                        <img class="img-responsive" src="__STATIC_URL__/static/images/gongneng.png">
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        {include file='public/footer'/}

    </div>
    </div>
</section>
<script src="__STATIC_URL__/static/laydate/laydate.js"></script>
<script>

    laydate.render({
        elem: '#starttime',
        type: 'datetime',
        range:'-',

        change: function(value, date,endDate){ //监听日期被切换


        }
    });



</script>
<script>
    $(function(){
        var activate=$("#act").val();
        if(activate=="1"){
            $('#self').bootstrapSwitch('setState', true);
            $("#activate").val("1");
        }
    })
</script>
<script>

    $("#self").on('switch-change', function (e, data) {
        var $el = $(data.el), value = data.value;
        if(value==true){
            $("#activate").val("1");
        }else{
            $("#activate").val("0");
        }
    });
</script>
<script>
    function btn(){
       var activate=$("#activate").val();
       var card_id=$("#card_id").val();
        $.ajax({
            url: "{:url('cardus/openbizmall')}",
            type: "post",
            data: {
                card_id:card_id,
                activate:activate
            },
            success: function (data) {
                 console.log(data);
                if(data.code==0){
                    layer.msg(data.message);
                    // setTimeout(function(){
                    //     window.location.href = "{:url('cardgifts/cardgiftrackcate')}";
                    //
                    // },1500)
                }else{
                    layer.msg(data.message);
                }
            }
        })
    }
</script>
</body>

</html>
